package com.tb.education.common.intf;

import cn.hutool.core.date.DateUtil;
import com.tb.education.common.packets.*;
import org.tio.core.ChannelContext;
import org.tio.utils.json.Json;

import java.time.LocalDateTime;

/**
 * @author wangze
 * @date 2020-07-12 10:51.
 **/
public abstract class AbsBaseHandler implements BaseHandlerIntf {
	/**
	 * @author tanyaowu
	 */
	public AbsBaseHandler() {
	}

	@Override
	public Object handler(DevicePacket packet, ChannelContext channelContext) throws Exception {

		MsgWrapper msgWrapper=DevicePacket.parseByte(packet.getBody());
		return handler(packet, msgWrapper.getHead(), msgWrapper.getBody(), channelContext);
	}

	public abstract Object handler(DevicePacket packet, Head head, String requestBody, ChannelContext channelContext) throws Exception;

	public static void main(String[] args) {
//		String str = "[123123123123]";
//		System.out.println(str.substring(1, str.length() - 2));
	}

}
